﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeBehind="CountryStatistics.aspx.cs"
 Inherits="Nivdal.CountryStatistics" Theme="SkinFile" %>

<%@ Register Assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadPlaceHolder" runat="server">
        
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:HiddenField ID="CountryIdHiddenField" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <div class="basic_element">
    <div class="red_title">
       <asp:Label ID="PageTitleLabel" runat="server" Text="Country statistics" CssClass="white_title"></asp:Label>
    </div>
    <div class="padding5">
        <asp:Label ID="ChartChooseTypeTitleLabel" runat="server" Text="Choose chart data:" SkinID="InfoLabel"  ></asp:Label>
        <asp:DropDownList ID="ChartTypeDDL" runat="server">
            <asp:ListItem Text="Num users total" Value="1"></asp:ListItem>
            <asp:ListItem Text="Logged last Week" Value="2"></asp:ListItem>
            <asp:ListItem Text="Logged 5 times last week" Value="3"></asp:ListItem>
            <asp:ListItem Text="Logged today" Value="4"></asp:ListItem>
            <asp:ListItem Text="Have sponsor" Value="5"></asp:ListItem>
            <asp:ListItem Text="Have coach" Value="6"></asp:ListItem>
            <asp:ListItem Text="Have stadium" Value="7"></asp:ListItem>
            <asp:ListItem Text="Posts in national forum" Value="8"></asp:ListItem>            
        </asp:DropDownList>
        <asp:Button ID="CreateChartButton" runat="server" Text="Create chart" OnClick="CreateChartButtonClick" CssClass="GreenSmallButtonStyle" />
        <br /><br />

        <asp:Panel ID="ChartPanel" runat="server" Visible="false">
        <br />

        <asp:Chart ID="Chart1" runat="server" Width="600" ImageLocation="~/Images/ChartsJunk/Chart#UID" ImageStorageMode="UseHttpHandler" 
        ImageType="Png" EnableViewState="true" >
            <Titles>
                <asp:Title Name="Title1" Text="Country statistics chart" Alignment="TopLeft" Font="Arial, 12px, style=Bold"></asp:Title>
            </Titles>
            <Legends>
                <asp:Legend IsTextAutoFit="true" Name="Default" Font="Arial, 12px, style=Bold"></asp:Legend>
            </Legends>
            <ChartAreas>
                <asp:ChartArea  Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" BackSecondaryColor="White" BackColor="Gainsboro" ShadowColor="Transparent" BackGradientStyle="TopBottom">
                    <area3dstyle Rotation="10" perspective="10" Inclination="15" IsRightAngleAxes="False" wallwidth="0" IsClustered="False"></area3dstyle>
					<axisy linecolor="64, 64, 64, 64" IsLabelAutoFit="False">
						<labelstyle font="Arial, 8.25pt, style=Bold" />
						<majorgrid linecolor="64, 64, 64, 64" />
					</axisy>
					<axisx linecolor="64, 64, 64, 64" IsLabelAutoFit="False">
						<labelstyle font="Arial, 8.25pt, style=Bold" IsStaggered="True" />
						<majorgrid linecolor="64, 64, 64, 64" />
					</axisx>
				</asp:ChartArea>
            </ChartAreas>
        </asp:Chart>
        </asp:Panel>
        <br /><br />
        
        
        <asp:Button ID="CheckAll" runat="server" OnClick="CheckAllButtonClick" Text="Check all" CssClass="GreenButtonTextStyle" />
        <asp:Button ID="ClearAll" runat="server" OnClick="ClearAllButtonClick" Text="Clear all" CssClass="GreySmallButtonStyle" />
    </div>
    </div>
    <div class="basic_element">
    <div class="red_title">
       <asp:Label ID="CountryStatsTitleLabel" runat="server" Text="All countries updated statistics:" CssClass="white_title"></asp:Label>
    </div>
    <div class="padding5">
        <asp:Gridview ID="AllCountriesStatsGridview" runat="server" AutoGenerateColumns="False"
         SkinID="SimpleProfessional" DataSourceID="AllCountriesDS" 
            EnableModelValidation="True">
            <RowStyle CssClass="NewsItemStyle" />
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="AddToChartCheckBox" runat="server" ToolTip="Check to add to chart" />
                        <asp:HiddenField ID="CountryIdHiddenField" runat="server" Value='<%# Eval("Country") %>' />
                        
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Image ID="FlagImage" runat="server" ImageUrl='<%# "~/Images/Flags/" + Eval("NationalFlag") %>' ToolTip='<%# Eval("CountryName") %>' />
                        &nbsp;
                        <asp:HyperLink ID="CountryLink" runat="server" NavigateUrl='<%# "~/Country.aspx?Id=" + Eval("Country") %>'
                         Text='<%# Eval("CountryName") %>'></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField HeaderText="Users" DataField="NumUsersTotal" />
                <asp:BoundField HeaderText="Active1" DataField="LoggedLastWeek" />
                <asp:BoundField HeaderText="Active5" DataField="Logged5TimesLastWeek" />
                <asp:BoundField HeaderText="Today" DataField="LoggedInToday" />
                <asp:BoundField HeaderText="Sponsor" DataField="HaveSponsor" />
                <asp:BoundField HeaderText="Coach" DataField="HaveCoach" />
                <asp:BoundField HeaderText="Stadium" DataField="HaveStadium" />
                <asp:BoundField HeaderText="Posts" DataField="PostsInNationalForum" />
            </Columns>      
        </asp:Gridview>
        <script language="javascript" type="text/javascript">

            $(function () {
                $("#ctl00_ctl00_ContentPlaceHolder3_ContentPlaceHolder1_AllCountriesStatsGridview").tablesorter();
            })
        

        </script>
        <asp:SqlDataSource ID="AllCountriesDS" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_GetLatestAllCountriesStats" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        <br /><br />
        <asp:Label ID="ChooseCountry" runat="server" Text="Display detailed stats for country:" SkinID="InfoLabel"></asp:Label>
        <asp:DropDownList ID="NationalityDropDownList" runat="server" DataSourceID="NationalitiesSqlDataSource"
            DataTextField="Name" DataValueField="Id" AutoPostBack="true" OnSelectedIndexChanged="BindCountryFromDDL">
        </asp:DropDownList>
        <asp:SqlDataSource ID="NationalitiesSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_GetListOfActiveCountries" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        <br />
        <asp:Label ID="CountryTitleLabel" runat="server" SkinID="InfoLabel"></asp:Label>
        <br />
        <asp:GridView ID="CountryDetailsGrid" runat="server" AutoGenerateColumns="false"
         SkinID="BigProfessional" AllowPaging="true" PageSize="50">
        <PagerSettings FirstPageText="<%$ Resources:Resource, FirstPage %>" LastPageText="<%$ Resources:Resource, LastPage %>"
            Mode="NumericFirstLast" PageButtonCount="5" Position="TopAndBottom" />
        <PagerStyle CssClass="pagination" HorizontalAlign="Center" /> 
        <RowStyle CssClass="NewsItemStyle" />
        <Columns>
            <asp:BoundField DataField="FormattedDate" HeaderText="Date" />
            <asp:BoundField HeaderText="Users" DataField="NumUsersTotal" />
            <asp:BoundField HeaderText="Active1" DataField="LoggedLastWeek" />
            <asp:BoundField HeaderText="Active5" DataField="Logged5TimesLastWeek" />
            <asp:BoundField HeaderText="Today" DataField="LoggedInToday" />
            <asp:BoundField HeaderText="Sponsor" DataField="HaveSponsor" />
            <asp:BoundField HeaderText="Coach" DataField="HaveCoach" />
            <asp:BoundField HeaderText="Stadium" DataField="HaveStadium" />
            <asp:BoundField HeaderText="Posts" DataField="PostsInNationalForum" />
        </Columns>
        </asp:GridView>
        <br />
        <asp:SqlDataSource ID="CountryDetailsDS" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_GetCountryStatsHistory" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>

       </div>
        </div>
    
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PageNamePlaceHolder" runat="server">
        <asp:Label ID="PageNameLabel" runat="server" Text="Country statistics" CssClass="PageNameContentStyle"></asp:Label>
</asp:Content>
